<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>房间更新管理</title>
    <div th:include="common::css"></div>
</head>
<body>
<br><br>
<form class="layui-form" action="" method="">
<!--    <input type="hidden" name="bookId" th:value="*{bean.bookId}" class="layui-input">-->
<input type="hidden" name="roomId" style="width:200px;" autocomplete="off" th:value="*{bean.roomId}" class="layui-input">
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">房间ID</label>-->
<!--        <div class="layui-input-block">-->
<!--            -->
<!--        </div>-->
<!--    </div>-->
    <div class="layui-form-item">
        <label class="layui-form-label">类型</label>
        <div class="layui-input-block">
            <input type="text" name="roomType" style="width:200px;" autocomplete="off" th:value="*{bean.roomType}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">价格</label>
        <div class="layui-input-block">
            <input type="text" name="roomPrice" style="width:200px;" autocomplete="off" th:value="*{bean.roomPrice}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">库存</label>
        <div class="layui-input-block">
            <input type="text" name="roomStock" style="width:200px;" autocomplete="off" th:value="*{bean.roomStock}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">图片名</label>
        <div class="layui-input-block">
            <input type="text" name="image" style="width:200px;" autocomplete="off" th:value="*{bean.image}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">描述</label>
        <div class="layui-input-block">
            <input type="text" name="remark" style="width:200px;" autocomplete="off" th:value="*{bean.remark}" class="layui-input">
        </div>
    </div>


    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo1" type="button">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<div th:include="common::js"></div>
<script>
    // JavaScript代码区域
    layui.use('element', function(){
        var element = layui.element;
    });
    layui.use(['form', 'layer'], function () {
            var form = layui.form;
            var layer = layui.layer;
            $ = layui.$;
        form.on('submit(demo1)', function (data) {
            $.post("/room/update",data.field,function (data) {
                console.log(data);
                // 关闭弹出层

                if(data){
                    layer.alert("编辑成功！");
                    layer.msg("编辑成功！",{icon: 6})
                    // $.msg("编辑成功！",{icon: 6});
                    parent.a();
                    var iframeIndex = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(iframeIndex);
                }else {
                    layer.alert("编辑失败！");
                    // layer.msg("编辑失败！",{icon: 5});//失败的表情
                }


            })



            // $.ajax({
            //     url: "/book/update",
            //     type: "post",
            //     dataType: "json",
            //     data:{'bookId':data.field.bookId,'userId':data.field.userId,'roomId':data.field.roomId,
            //         'bookPhone':data.field.bookPhone,'email':data.field.email,'bookPrice':data.field.bookPrice,'bookState':data.field.bookState,
            //         'bookName':data.field.bookName,'arriveDate':data.field.arriveDate},
            //     success: function (res) {
            //         var json=JSON.parse(res);
            //         if (json==true) {
            //             layer.msg("编辑成功！",{icon: 6});
            //             parent.a();
            //         } else {
            //             layer.msg("编辑失败！",{icon: 5});//失败的表情
            //         }
            //     }
            // });


        });
    });
</script>
</body>
</html>